<template>
    <div class="route">
        <h1>{{num}}</h1>
        <button @click="add">路由参数++</button>
    </div>
</template>
<script>
export default {
    data() {
        return {
            num:2,
        }
    },
    methods: {
        add(){
            this.num = Number(this.$route.params.id)+1
            this.$router.push(`/route/${this.num}`)
        }
    },
    beforeRouteUpdate (to, from, next) { ///适用于动态路由
        console.log('我更新了吗');
       next()
    }
   
}
</script>
